<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>栈</title>
	</head>
	<body>
		<input type="button" value="入栈" id="btn1"/>
		<input type="button" value="出栈" id="btn2"/>
		<script type="text/javascript">
			var stack=[];
			var push=document.getElementById("btn1");
			var pop=document.getElementById("btn2");
			push.onclick=function (e) {
				var r=parseInt(Math.random()*100);//parseInt() 函数可解析一个字符串，并返回一个整数
				stack.push(r);
				console.log(stack.toString());
			}
			pop.onclick=function (e) {
				var v=stack.pop();
				alert(v+"出栈");
				console.log(stack.toString());
			}
		</script>
	</body>
</html>
